package view.mediator.weapon.flute
{
	import model.weapon.WeaponModel;
	
	import org.robotlegs.mvcs.StarlingMediator;
	
	import view.component.weapon.flute.FluteStaffView;
	import view.event.weapon.flute.FluteStaffViewEvent;
	
	
	/**
	 * FluteStaffView界面中介
	 * @author £iang
	 * 
	 */	
	public class FluteStaffViewMediator extends StarlingMediator
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** FluteStaffView界面 */
		[Inject]
		public var fluteStaffView:FluteStaffView;
		[Inject]
		public var weaponModel:WeaponModel;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 注册函数 
		 * 
		 */		
		override public function onRegister():void
		{
			addContextListener( FluteStaffViewEvent.SHOW_MELODY, showMelodyHandler );
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		/**
		 * 处理请求显示乐谱页派发的消息 
		 * @param event 请求显示乐谱页派发的消息 
		 * 
		 */		
		protected function showMelodyHandler( event:FluteStaffViewEvent ):void
		{
			fluteStaffView.gotoMelody( weaponModel.curShowMelodyType );
		}
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 移除函数 
		 * 
		 */		
		override public function onRemove():void
		{
			removeContextListener( FluteStaffViewEvent.SHOW_MELODY, showMelodyHandler );
			fluteStaffView.clearNavi();
			super.onRemove();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function FluteStaffViewMediator()
		{
			super();
		}
	}
}